#!/usr/bin/env bash

function check() {
    {
        function check_bash() {
            if type bash >/dev/null 2>&1; then
                :
            else
                echo "bash: command not found."
            fi
        }
        function check_grep() {
            if type grep >/dev/null 2>&1; then
                :
            else
                echo "grep: command not found."
            fi
        }
        function check_awk() {
            if type awk >/dev/null 2>&1; then
                :
            else
                echo "awk: command not found."
            fi
        }
        function check_sed() {
            if type sed >/dev/null 2>&1; then
                :
            else
                echo "sed: command not found."
            fi
        }
        function check_cat() {
            if type cat >/dev/null 2>&1; then
                :
            else
                echo "cat: command not found."
            fi
        }
        function check_bc() {
            if type bc >/dev/null 2>&1; then
                :
            else
                echo "bc: command not found."
            fi
        }
        result="$(check_bash && check_grep && check_awk && check_sed && check_cat && check_bc)"
        readonly result
        if [[ -z "${result}" ]]; then
            :
        else
            echo "${result}" 1>&2 && exit 1
        fi
    }
}
